package com.xiaomai.Action;

import java.util.HashMap;
import java.util.Map;

import oracle.net.aso.b;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;
import com.xiaomai.entity.Cart;
import com.xiaomai.entity.Classification;
import com.xiaomai.server.CartService;
import com.xiaomai.server.CartServiceImpl;

public class CartAction extends ActionSupport{
	public String id;
	public int sum;
	public ValueStack v=ActionContext.getContext().getValueStack();
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String cartAction(){
		//购物车
		CartService c=new CartServiceImpl();
		Cart cart = (Cart) v.findValue("#session.cart");
		if(cart==null){
			cart=new Cart();
		}
		Cart cartAdd = c.CartAdd(cart, id);
		v.setValue( "#session.cart", cartAdd);
		return "cart_success";
	}
	
	public String DetelAction(){
		//删除		
		CartService c=new CartServiceImpl();
		Cart cart = (Cart) v.findValue("#session.cart");
		c.CartDetele(cart, id);
		
		return "detele_success"; 
		
	}
	
	public String Alteration(){
		//变更	
		CartService c=new CartServiceImpl();
		Cart cart = (Cart) v.findValue("#session.cart");
		c.alteration(cart, id, sum);
		
		return "alter_success"; 
		
	}
	
}





